<? 
    require "functions.php";
    //conexao('labnotes');
    
    //echo json_encode ($fields);
    
    formToDB('tabela', '', 'insert', NULL);
    
      
function formToDB($table, $exceptions, $sql_type, $sql_condition){    
    
    $fields = '';
    $values = '';
    
    //echo json_encode ($table);
    echo json_encode ($_POST[$field]);
/*    foreach ($_POST as $field => $value){    
        if (!strstr($exceptions,$field)){
            $value = mysql_real_escape_string($value);
            if ($sql_type == 'insert'){
                $fields .= "$field, ";
                $values .= "'$value', ";
                }
                else {
                $fields .= "$field = '$value', ";
                }
            }
    }
    echo json_encode ($fields);
*/    
/*    
     remove trailing ", " from $fields and $values
    $fields = preg_replace('/, $/', '', $fields);
    $values = preg_replace('/, $/', '', $values);
    
     create sql statement
    $sql = "INSERT INTO $table ($fields) VALUES ($values)";
 
     execute sql
    if (mysql_query($sql)){
        return true;
    }
    else {
        echo mysql_error();
        return false;
    }
*/
}       
?>